Skip to content

feat(#821): Unify local and refresh providers into one#822

Merged
phoenix-ru merged 24 commits intomainfrom
821/feat/unify-local-refresh-providers
Aug 22, 2024
Merged

feat(#821): Unify local and refresh providers into one#822
phoenix-ru merged 24 commits intomainfrom
821/feat/unify-local-refresh-providers

Conversation

@zoey-kaiser
Copy link
Member

@zoey-kaiser zoey-kaiser commented Jul 19, 2024

🔗 Linked issue

closes #821, #730
improved on #731

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Removes the separation of the local and refresh providers and adds the extended logic from the refresh provider into an additional refresh config property of the local provider

Simple migration guide:

export default defineNuxtConfig({
	auth: {
		provider: {
-			type: 'refresh',
+			type: 'local',
			endpoints: {
				signIn: { path: '/signIn', method: 'post' },
-				refresh: { path: '/refresh', method: 'post' } 
			},
-			refreshToken: { // Refresh token config },
-			refreshOnlyToken: true,
+			refresh: {
+				isEnabled: true,
+				endpoint:  { path: '/refresh', method: 'post' },
+				refreshOnlyToken: true,
+				token: { // Refresh token config },
+			}
		}
	}
})

New local with refresh config:

export default defineNuxtConfig({
    auth: {
        provider: {
	    type: 'local',
            pages: {
                login: '/login'
            },
            endpoints: {
                signIn: { path: '/login', method: 'post' },
                signOut: { path: '/logout', method: 'post' },
                signUp: { path: '/register', method: 'post' },
                getSession: { path: '/session', method: 'get' }
            },
            token: {
                signInResponseTokenPointer: '/token',
                type: 'Bearer',
                cookieName: 'auth.token',
                headerName: 'Authorization',
                maxAgeInSeconds: 30 * 60, // 30 minutes
                sameSiteAttribute: 'lax',
                secureCookieAttribute: false,
                cookieDomain: ''
            },
            session: {
                dataType: { id: 'string | number' },
                dataResponsePointer: '/'
            },
            refresh: {
                isEnabled: true,
                endpoint:  { path: '/refresh', method: 'post' },
                refreshOnlyToken: true,
                token: {
                    signInResponseRefreshTokenPointer: '/refreshToken',
                    refreshRequestTokenPointer: '/refreshToken',
                    cookieName: 'auth.refresh-token',
                    maxAgeInSeconds: 60 * 60 * 24 * 7, // 7 days
                    sameSiteAttribute: 'lax',
                    secureCookieAttribute: false,
                    cookieDomain: ''
                }
	    }
        }
    }
})

📝 Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@zoey-kaiser zoey-kaiser added next provider-local An issue with the local provider provider-refresh An issue with the refresh provider breaking-change A change will changes that require at least a minor release. 1.x and removed next labels Jul 19, 2024
@phoenix-ru phoenix-ru changed the base branch from main to next July 25, 2024 12:21
@zoey-kaiser zoey-kaiser changed the base branch from next to main August 8, 2024 17:53
@zoey-kaiser zoey-kaiser removed the 1.x label Aug 8, 2024
@zoey-kaiser zoey-kaiser requested a review from phoenix-ru August 9, 2024 12:33
Copy link
Collaborator

@phoenix-ru phoenix-ru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, just one question

@phoenix-ru phoenix-ru merged commit b09b14e into main Aug 22, 2024
@phoenix-ru phoenix-ru deleted the 821/feat/unify-local-refresh-providers branch August 22, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change A change will changes that require at least a minor release. provider-local An issue with the local provider provider-refresh An issue with the refresh provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify local and refresh provider

2 participants